<template>
  <div class="resumes-center">
    <!-- 页面头部 -->
    <div class="page-header">
      <div class="header-left">
        <h1 class="page-title">简历中心</h1>
        <p class="page-desc">管理所有投递的简历，筛选优质候选人</p>
      </div>
      <div class="header-right">
        <el-button type="primary" @click="handleBatchDownload" :disabled="selectedResumes.length === 0">
          <el-icon>
            <Download />
          </el-icon>
          批量下载
        </el-button>
        <el-button type="success" @click="handleExport">
          <el-icon>
            <DocumentCopy />
          </el-icon>
          导出数据
        </el-button>
      </div>
    </div>

    <!-- 统计卡片 -->
    <el-row :gutter="20" class="stats-row">
      <el-col :xs="12" :sm="6">
        <div class="stat-card total">
          <div class="stat-icon">
            <el-icon>
              <Document />
            </el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">{{ stats.total }}</div>
            <div class="stat-label">总简历数</div>
          </div>
        </div>
      </el-col>

      <el-col :xs="12" :sm="6">
        <div class="stat-card new">
          <div class="stat-icon">
            <el-icon>
              <Plus />
            </el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">{{ stats.newToday }}</div>
            <div class="stat-label">今日新增</div>
          </div>
        </div>
      </el-col>

      <el-col :xs="12" :sm="6">
        <div class="stat-card pending">
          <div class="stat-icon">
            <el-icon>
              <Clock />
            </el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">{{ stats.pending }}</div>
            <div class="stat-label">待处理</div>
          </div>
        </div>
      </el-col>

      <el-col :xs="12" :sm="6">
        <div class="stat-card matched">
          <div class="stat-icon">
            <el-icon>
              <Check />
            </el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">{{ stats.matched }}</div>
            <div class="stat-label">已匹配</div>
          </div>
        </div>
      </el-col>
    </el-row>

    <!-- 搜索筛选 -->
    <el-card class="search-card">
      <el-form :model="searchForm" inline>
        <el-form-item label="候选人姓名">
          <el-input v-model="searchForm.candidateName" placeholder="请输入候选人姓名" clearable style="width: 150px" />
        </el-form-item>

        <el-form-item label="投递职位">
          <el-select v-model="searchForm.jobId" placeholder="请选择职位" clearable filterable style="width: 200px">
            <el-option v-for="job in jobList" :key="job.id" :label="job.title" :value="job.id" />
          </el-select>
        </el-form-item>

        <el-form-item label="简历状态">
          <el-select v-model="searchForm.status" placeholder="请选择状态" clearable style="width: 120px">
            <el-option label="待处理" value="pending" />
            <el-option label="已查看" value="viewed" />
            <el-option label="初筛通过" value="screening_passed" />
            <el-option label="面试邀请" value="interview_invited" />
            <el-option label="面试通过" value="interview_passed" />
            <el-option label="已拒绝" value="rejected" />
            <el-option label="已录用" value="hired" />
          </el-select>
        </el-form-item>

        <el-form-item label="投递时间">
          <el-date-picker v-model="searchForm.dateRange" type="daterange" range-separator="至" start-placeholder="开始日期"
            end-placeholder="结束日期" style="width: 240px" />
        </el-form-item>

        <el-form-item label="学历要求">
          <el-select v-model="searchForm.education" placeholder="请选择学历" clearable style="width: 120px">
            <el-option label="高中" value="高中" />
            <el-option label="大专" value="大专" />
            <el-option label="本科" value="本科" />
            <el-option label="硕士" value="硕士" />
            <el-option label="博士" value="博士" />
          </el-select>
        </el-form-item>

        <el-form-item label="工作经验">
          <el-select v-model="searchForm.experience" placeholder="请选择经验" clearable style="width: 120px">
            <el-option label="应届生" value="0" />
            <el-option label="1-3年" value="1-3" />
            <el-option label="3-5年" value="3-5" />
            <el-option label="5-10年" value="5-10" />
            <el-option label="10年以上" value="10+" />
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="handleSearch">
            <el-icon>
              <Search />
            </el-icon>
            搜索
          </el-button>
          <el-button @click="handleReset">
            <el-icon>
              <Refresh />
            </el-icon>
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 简历列表 -->
    <el-card class="table-card">
      <!-- 列表工具栏 -->
      <div class="table-toolbar">
        <div class="toolbar-left">
          <el-checkbox v-model="selectAll" :indeterminate="isIndeterminate" @change="handleSelectAll">
            全选
          </el-checkbox>
          <span class="selected-info" v-if="selectedResumes.length > 0">
            已选择 {{ selectedResumes.length }} 份简历
          </span>
        </div>

        <div class="toolbar-right">
          <el-button-group>
            <el-button :type="viewMode === 'list' ? 'primary' : 'default'" @click="viewMode = 'list'">
              <el-icon>
                <List />
              </el-icon>
              列表
            </el-button>
            <el-button :type="viewMode === 'card' ? 'primary' : 'default'" @click="viewMode = 'card'">
              <el-icon>
                <Grid />
              </el-icon>
              卡片
            </el-button>
          </el-button-group>
        </div>
      </div>

      <!-- 列表视图 -->
      <el-table v-if="viewMode === 'list'" :data="tableData" v-loading="loading" stripe style="width: 100%"
        @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" />

        <el-table-column prop="id" label="ID" width="80" />

        <!-- 候选人信息 -->
        <el-table-column label="候选人信息" min-width="200">
          <template #default="{ row }">
            <div class="candidate-info">
              <el-avatar :size="40" :src="row.avatar">
                <el-icon>
                  <User />
                </el-icon>
              </el-avatar>
              <div class="info-content">
                <div class="candidate-name">{{ row.candidateName }}</div>
                <div class="candidate-contact">
                  <span>{{ row.phone }}</span>
                  <span class="email">{{ row.email }}</span>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>

        <!-- 投递职位 -->
        <el-table-column label="投递职位" min-width="150">
          <template #default="{ row }">
            <div class="job-info">
              <div class="job-title">{{ row.jobTitle }}</div>
              <div class="job-department">{{ row.department }}</div>
            </div>
          </template>
        </el-table-column>

        <!-- 基本信息 -->
        <el-table-column label="基本信息" min-width="120">
          <template #default="{ row }">
            <div class="basic-info">
              <div>{{ row.education }}</div>
              <div>{{ row.experience }}</div>
            </div>
          </template>
        </el-table-column>

        <!-- 期望薪资 -->
        <el-table-column label="期望薪资" width="100">
          <template #default="{ row }">
            <span class="salary">{{ row.expectedSalary }}</span>
          </template>
        </el-table-column>

        <!-- 简历状态 -->
        <el-table-column label="状态" width="120">
          <template #default="{ row }">
            <el-tag :type="getStatusTagType(row.status)">
              {{ getStatusText(row.status) }}
            </el-tag>
          </template>
        </el-table-column>

        <!-- 匹配度 -->
        <el-table-column label="匹配度" width="100">
          <template #default="{ row }">
            <div class="match-score">
              <el-progress :percentage="row.matchScore" :color="getMatchColor(row.matchScore)" :stroke-width="6"
                text-inside />
            </div>
          </template>
        </el-table-column>

        <!-- 投递时间 -->
        <el-table-column label="投递时间" width="180">
          <template #default="{ row }">
            {{ formatDate(row.applyTime) }}
          </template>
        </el-table-column>

        <!-- 操作 -->
        <el-table-column label="操作" width="200" fixed="right">
          <template #default="{ row }">
            <el-button type="primary" link @click="handleViewResume(row)">
              <el-icon>
                <View />
              </el-icon>
              查看
            </el-button>
            <el-button type="success" link @click="handleDownload(row)">
              <el-icon>
                <Download />
              </el-icon>
              下载
            </el-button>
            <el-dropdown @command="(command) => handleAction(command, row)">
              <el-button type="primary" link>
                更多
                <el-icon>
                  <ArrowDown />
                </el-icon>
              </el-button>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item command="invite">
                    <el-icon>
                      <VideoCamera />
                    </el-icon>
                    邀请面试
                  </el-dropdown-item>
                  <el-dropdown-item command="reject">
                    <el-icon>
                      <Close />
                    </el-icon>
                    拒绝
                  </el-dropdown-item>
                  <el-dropdown-item command="star">
                    <el-icon>
                      <Star />
                    </el-icon>
                    收藏
                  </el-dropdown-item>
                  <el-dropdown-item command="note">
                    <el-icon>
                      <EditPen />
                    </el-icon>
                    添加备注
                  </el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>

      <!-- 卡片视图 -->
      <div v-else class="card-view">
        <el-row :gutter="20">
          <el-col v-for="resume in tableData" :key="resume.id" :xs="24" :sm="12" :md="8" :lg="6">
            <div class="resume-card" :class="{ selected: selectedResumes.includes(resume.id) }">
              <div class="card-header">
                <el-checkbox :model-value="selectedResumes.includes(resume.id)"
                  @change="(checked) => handleCardSelect(checked, resume.id)" />
                <el-dropdown @command="(command) => handleAction(command, resume)">
                  <el-button type="text" class="more-btn">
                    <el-icon>
                      <MoreFilled />
                    </el-icon>
                  </el-button>
                  <template #dropdown>
                    <el-dropdown-menu>
                      <el-dropdown-item command="invite">邀请面试</el-dropdown-item>
                      <el-dropdown-item command="reject">拒绝</el-dropdown-item>
                      <el-dropdown-item command="star">收藏</el-dropdown-item>
                      <el-dropdown-item command="note">添加备注</el-dropdown-item>
                    </el-dropdown-menu>
                  </template>
                </el-dropdown>
              </div>

              <div class="card-content" @click="handleViewResume(resume)">
                <div class="candidate-avatar">
                  <el-avatar :size="60" :src="resume.avatar">
                    <el-icon>
                      <User />
                    </el-icon>
                  </el-avatar>
                </div>

                <div class="candidate-details">
                  <h3 class="candidate-name">{{ resume.candidateName }}</h3>
                  <p class="job-title">{{ resume.jobTitle }}</p>

                  <div class="candidate-tags">
                    <el-tag size="small">{{ resume.education }}</el-tag>
                    <el-tag size="small">{{ resume.experience }}</el-tag>
                  </div>

                  <div class="match-info">
                    <span class="match-label">匹配度：</span>
                    <el-progress :percentage="resume.matchScore" :color="getMatchColor(resume.matchScore)"
                      :stroke-width="4" :show-text="false" style="width: 60px" />
                    <span class="match-value">{{ resume.matchScore }}%</span>
                  </div>

                  <div class="card-footer">
                    <el-tag :type="getStatusTagType(resume.status)" size="small">
                      {{ getStatusText(resume.status) }}
                    </el-tag>
                    <span class="apply-time">{{ formatDate(resume.applyTime) }}</span>
                  </div>
                </div>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>

      <!-- 分页 -->
      <div class="pagination-container">
        <el-pagination v-model:current-page="pagination.current" v-model:page-size="pagination.size"
          :page-sizes="[10, 20, 50, 100]" :total="pagination.total" layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>
    </el-card>

    <!-- 简历详情对话框 -->
    <el-dialog v-model="resumeDialogVisible" title="简历详情" width="80%" top="5vh" @close="handleResumeDialogClose">
      <div v-if="currentResume" class="resume-detail">
        <!-- 候选人基本信息 -->
        <div class="resume-header">
          <el-avatar :size="80" :src="currentResume.avatar">
            <el-icon>
              <User />
            </el-icon>
          </el-avatar>
          <div class="header-info">
            <h2>{{ currentResume.candidateName }}</h2>
            <p class="contact-info">
              <span>{{ currentResume.phone }}</span>
              <span>{{ currentResume.email }}</span>
            </p>
            <div class="basic-tags">
              <el-tag>{{ currentResume.education }}</el-tag>
              <el-tag>{{ currentResume.experience }}</el-tag>
              <el-tag>期望薪资：{{ currentResume.expectedSalary }}</el-tag>
            </div>
          </div>
          <div class="header-actions">
            <el-button type="primary" @click="handleInviteInterview(currentResume)">
              <el-icon>
                <VideoCamera />
              </el-icon>
              邀请面试
            </el-button>
            <el-button @click="handleDownload(currentResume)">
              <el-icon>
                <Download />
              </el-icon>
              下载简历
            </el-button>
          </div>
        </div>

        <!-- 简历内容 -->
        <el-tabs v-model="activeTab" class="resume-tabs">
          <el-tab-pane label="基本信息" name="basic">
            <div class="resume-section">
              <h3>个人信息</h3>
              <el-descriptions :column="2" border>
                <el-descriptions-item label="姓名">{{ currentResume.candidateName }}</el-descriptions-item>
                <el-descriptions-item label="性别">{{ currentResume.gender || '未填写' }}</el-descriptions-item>
                <el-descriptions-item label="年龄">{{ currentResume.age || '未填写' }}</el-descriptions-item>
                <el-descriptions-item label="学历">{{ currentResume.education }}</el-descriptions-item>
                <el-descriptions-item label="工作经验">{{ currentResume.experience }}</el-descriptions-item>
                <el-descriptions-item label="现居地">{{ currentResume.location || '未填写' }}</el-descriptions-item>
                <el-descriptions-item label="期望薪资">{{ currentResume.expectedSalary }}</el-descriptions-item>
                <el-descriptions-item label="期望地点">{{ currentResume.expectedLocation || '未填写' }}</el-descriptions-item>
              </el-descriptions>
            </div>
          </el-tab-pane>

          <el-tab-pane label="工作经历" name="experience">
            <div class="resume-section">
              <h3>工作经历</h3>
              <div v-if="currentResume.workExperience && currentResume.workExperience.length > 0">
                <div v-for="(exp, index) in currentResume.workExperience" :key="index" class="experience-item">
                  <div class="exp-header">
                    <h4>{{ exp.company }} - {{ exp.position }}</h4>
                    <span class="exp-duration">{{ exp.startDate }} 至 {{ exp.endDate }}</span>
                  </div>
                  <p class="exp-description">{{ exp.description }}</p>
                </div>
              </div>
              <el-empty v-else description="暂无工作经历" />
            </div>
          </el-tab-pane>

          <el-tab-pane label="教育背景" name="education">
            <div class="resume-section">
              <h3>教育背景</h3>
              <div v-if="currentResume.educationBackground && currentResume.educationBackground.length > 0">
                <div v-for="(edu, index) in currentResume.educationBackground" :key="index" class="education-item">
                  <div class="edu-header">
                    <h4>{{ edu.school }} - {{ edu.major }}</h4>
                    <span class="edu-duration">{{ edu.startDate }} 至 {{ edu.endDate }}</span>
                  </div>
                  <p class="edu-degree">{{ edu.degree }}</p>
                </div>
              </div>
              <el-empty v-else description="暂无教育背景" />
            </div>
          </el-tab-pane>

          <el-tab-pane label="技能特长" name="skills">
            <div class="resume-section">
              <h3>技能特长</h3>
              <div v-if="currentResume.skills && currentResume.skills.length > 0" class="skills-list">
                <el-tag v-for="skill in currentResume.skills" :key="skill" class="skill-tag">
                  {{ skill }}
                </el-tag>
              </div>
              <el-empty v-else description="暂无技能信息" />
            </div>
          </el-tab-pane>

          <el-tab-pane label="自我评价" name="summary">
            <div class="resume-section">
              <h3>自我评价</h3>
              <p v-if="currentResume.selfEvaluation" class="self-evaluation">
                {{ currentResume.selfEvaluation }}
              </p>
              <el-empty v-else description="暂无自我评价" />
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
  Download,
  DocumentCopy,
  Document,
  Plus,
  Clock,
  Check,
  Search,
  Refresh,
  List,
  Grid,
  User,
  View,
  ArrowDown,
  VideoCamera,
  Close,
  Star,
  EditPen,
  MoreFilled
} from '@element-plus/icons-vue'

// 响应式数据
const loading = ref(false)
const viewMode = ref('list') // 'list' | 'card'
const selectAll = ref(false)
const selectedResumes = ref<number[]>([])
const resumeDialogVisible = ref(false)
const currentResume = ref(null)
const activeTab = ref('basic')

// 统计数据
const stats = ref({
  total: 156,
  newToday: 12,
  pending: 45,
  matched: 23
})

// 搜索表单
const searchForm = reactive({
  candidateName: '',
  jobId: null,
  status: '',
  dateRange: null,
  education: '',
  experience: ''
})

// 分页数据
const pagination = reactive({
  current: 1,
  size: 20,
  total: 0
})

// 职位列表
const jobList = ref([
  { id: 1, title: 'Java开发工程师' },
  { id: 2, title: '前端开发工程师' },
  { id: 3, title: '产品经理' },
  { id: 4, title: 'UI设计师' }
])

// 简历数据
const tableData = ref([
  {
    id: 1,
    candidateName: '张小明',
    phone: '13800138001',
    email: 'zhangxiaoming@email.com',
    avatar: '',
    jobTitle: 'Java开发工程师',
    department: '技术部',
    education: '本科',
    experience: '3-5年',
    expectedSalary: '15-20K',
    status: 'pending',
    matchScore: 85,
    applyTime: '2024-01-20T10:30:00',
    gender: '男',
    age: 28,
    location: '北京',
    expectedLocation: '北京',
    workExperience: [
      {
        company: '阿里巴巴',
        position: 'Java开发工程师',
        startDate: '2021-03',
        endDate: '2024-01',
        description: '负责电商平台后端开发，参与微服务架构设计'
      }
    ],
    educationBackground: [
      {
        school: '北京大学',
        major: '计算机科学与技术',
        degree: '本科',
        startDate: '2017-09',
        endDate: '2021-06'
      }
    ],
    skills: ['Java', 'Spring Boot', 'MySQL', 'Redis', 'Docker'],
    selfEvaluation: '具有3年Java开发经验，熟悉Spring Boot框架，有大型项目开发经验。'
  },
  {
    id: 2,
    candidateName: '李小红',
    phone: '13800138002',
    email: 'lixiaohong@email.com',
    avatar: '',
    jobTitle: '前端开发工程师',
    department: '技术部',
    education: '本科',
    experience: '1-3年',
    expectedSalary: '12-15K',
    status: 'viewed',
    matchScore: 78,
    applyTime: '2024-01-19T14:20:00',
    gender: '女',
    age: 25,
    location: '上海',
    expectedLocation: '上海',
    workExperience: [
      {
        company: '腾讯',
        position: '前端开发工程师',
        startDate: '2022-07',
        endDate: '2024-01',
        description: '负责Web前端开发，使用Vue.js构建用户界面'
      }
    ],
    educationBackground: [
      {
        school: '复旦大学',
        major: '软件工程',
        degree: '本科',
        startDate: '2018-09',
        endDate: '2022-06'
      }
    ],
    skills: ['Vue.js', 'React', 'TypeScript', 'Webpack', 'Element Plus'],
    selfEvaluation: '熟悉前端开发技术栈，有良好的代码规范和团队协作能力。'
  }
])

// 计算属性
const isIndeterminate = computed(() => {
  const selectedCount = selectedResumes.value.length
  const totalCount = tableData.value.length
  return selectedCount > 0 && selectedCount < totalCount
})

// 方法定义

/**
 * 获取状态标签类型
 */
const getStatusTagType = (status: string) => {
  const typeMap: Record<string, string> = {
    'pending': 'warning',
    'viewed': 'info',
    'screening_passed': 'primary',
    'interview_invited': 'success',
    'interview_passed': 'success',
    'rejected': 'danger',
    'hired': 'success'
  }
  return typeMap[status] || 'info'
}

/**
 * 获取状态文本
 */
const getStatusText = (status: string) => {
  const textMap: Record<string, string> = {
    'pending': '待处理',
    'viewed': '已查看',
    'screening_passed': '初筛通过',
    'interview_invited': '面试邀请',
    'interview_passed': '面试通过',
    'rejected': '已拒绝',
    'hired': '已录用'
  }
  return textMap[status] || status
}

/**
 * 获取匹配度颜色
 */
const getMatchColor = (score: number) => {
  if (score >= 80) return '#67c23a'
  if (score >= 60) return '#e6a23c'
  return '#f56c6c'
}

/**
 * 格式化日期
 */
const formatDate = (dateString: string) => {
  return new Date(dateString).toLocaleString('zh-CN')
}

/**
 * 搜索
 */
const handleSearch = () => {
  pagination.current = 1
  loadData()
}

/**
 * 重置搜索
 */
const handleReset = () => {
  Object.assign(searchForm, {
    candidateName: '',
    jobId: null,
    status: '',
    dateRange: null,
    education: '',
    experience: ''
  })
  handleSearch()
}

/**
 * 全选
 */
const handleSelectAll = (checked: boolean) => {
  if (checked) {
    selectedResumes.value = tableData.value.map(item => item.id)
  } else {
    selectedResumes.value = []
  }
}

/**
 * 选择改变
 */
const handleSelectionChange = (selection: any[]) => {
  selectedResumes.value = selection.map(item => item.id)
  selectAll.value = selection.length === tableData.value.length
}

/**
 * 卡片选择
 */
const handleCardSelect = (checked: boolean, id: number) => {
  if (checked) {
    selectedResumes.value.push(id)
  } else {
    const index = selectedResumes.value.indexOf(id)
    if (index > -1) {
      selectedResumes.value.splice(index, 1)
    }
  }
  selectAll.value = selectedResumes.value.length === tableData.value.length
}

/**
 * 查看简历
 */
const handleViewResume = (resume: any) => {
  currentResume.value = resume
  resumeDialogVisible.value = true

  // 标记为已查看
  if (resume.status === 'pending') {
    resume.status = 'viewed'
    // TODO: 调用API更新状态
  }
}

/**
 * 下载简历
 */
const handleDownload = (resume: any) => {
  ElMessage.info(`下载简历：${resume.candidateName}`)
  // TODO: 实现下载功能
}

/**
 * 批量下载
 */
const handleBatchDownload = () => {
  ElMessage.info(`批量下载 ${selectedResumes.value.length} 份简历`)
  // TODO: 实现批量下载功能
}

/**
 * 导出数据
 */
const handleExport = () => {
  ElMessage.info('导出简历数据')
  // TODO: 实现导出功能
}

/**
 * 处理操作
 */
const handleAction = (command: string, resume: any) => {
  switch (command) {
    case 'invite':
      handleInviteInterview(resume)
      break
    case 'reject':
      handleReject(resume)
      break
    case 'star':
      handleStar(resume)
      break
    case 'note':
      handleAddNote(resume)
      break
  }
}

/**
 * 邀请面试
 */
const handleInviteInterview = (resume: any) => {
  ElMessage.success(`已邀请 ${resume.candidateName} 参加面试`)
  resume.status = 'interview_invited'
  // TODO: 调用API发送面试邀请
}

/**
 * 拒绝候选人
 */
const handleReject = (resume: any) => {
  ElMessageBox.confirm(
    `确定要拒绝候选人「${resume.candidateName}」吗？`,
    '拒绝确认',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }
  ).then(() => {
    resume.status = 'rejected'
    ElMessage.success('已拒绝该候选人')
    // TODO: 调用API更新状态
  })
}

/**
 * 收藏简历
 */
const handleStar = (resume: any) => {
  ElMessage.success(`已收藏 ${resume.candidateName} 的简历`)
  // TODO: 实现收藏功能
}

/**
 * 添加备注
 */
const handleAddNote = (resume: any) => {
  ElMessage.info(`为 ${resume.candidateName} 添加备注`)
  // TODO: 实现添加备注功能
}

/**
 * 简历对话框关闭
 */
const handleResumeDialogClose = () => {
  currentResume.value = null
  activeTab.value = 'basic'
}

/**
 * 分页大小改变
 */
const handleSizeChange = (size: number) => {
  pagination.size = size
  loadData()
}

/**
 * 当前页改变
 */
const handleCurrentChange = (current: number) => {
  pagination.current = current
  loadData()
}

/**
 * 加载数据
 */
const loadData = () => {
  loading.value = true
  // TODO: 调用API获取数据
  setTimeout(() => {
    pagination.total = 156
    loading.value = false
  }, 500)
}

// 生命周期
onMounted(() => {
  loadData()
})
</script>

<style scoped>
.resumes-center {
  padding: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.header-right {
  display: flex;
  gap: 12px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: #303133;
  margin: 0 0 4px 0;
}

.page-desc {
  color: #909399;
  margin: 0;
}

.stats-row {
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s;
  border-left: 4px solid;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card.total {
  border-left-color: #409eff;
}

.stat-card.new {
  border-left-color: #67c23a;
}

.stat-card.pending {
  border-left-color: #e6a23c;
}

.stat-card.matched {
  border-left-color: #f56c6c;
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}

.total .stat-icon {
  background: #409eff;
}

.new .stat-icon {
  background: #67c23a;
}

.pending .stat-icon {
  background: #e6a23c;
}

.matched .stat-icon {
  background: #f56c6c;
}

.stat-content {
  flex: 1;
}

.stat-number {
  font-size: 24px;
  font-weight: bold;
  color: #303133;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: #909399;
}

.search-card {
  margin-bottom: 20px;
}

.table-card {
  border-radius: 8px;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e4e7ed;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.selected-info {
  color: #409eff;
  font-size: 14px;
}

.candidate-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-content {
  flex: 1;
}

.candidate-name {
  font-weight: 600;
  color: #303133;
  margin-bottom: 4px;
}

.candidate-contact {
  font-size: 12px;
  color: #909399;
}

.candidate-contact .email {
  margin-left: 8px;
}

.job-info {
  line-height: 1.5;
}

.job-title {
  font-weight: 500;
  color: #303133;
  margin-bottom: 2px;
}

.job-department {
  font-size: 12px;
  color: #909399;
}

.basic-info {
  line-height: 1.5;
  font-size: 14px;
}

.salary {
  color: #f56c6c;
  font-weight: 500;
}

.match-score {
  width: 80px;
}

.card-view {
  margin-top: 16px;
}

.resume-card {
  background: white;
  border: 1px solid #e4e7ed;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  transition: all 0.3s;
  cursor: pointer;
}

.resume-card:hover {
  border-color: #409eff;
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.2);
}

.resume-card.selected {
  border-color: #409eff;
  background-color: #f0f9ff;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.more-btn {
  color: #909399;
}

.card-content {
  text-align: center;
}

.candidate-avatar {
  margin-bottom: 12px;
}

.candidate-details h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
  color: #303133;
}

.candidate-details p {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: #666;
}

.candidate-tags {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 12px;
}

.match-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
}

.match-label {
  color: #666;
}

.match-value {
  color: #303133;
  font-weight: 500;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.apply-time {
  color: #909399;
}

.pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.resume-detail {
  max-height: 70vh;
  overflow-y: auto;
}

.resume-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 20px;
}

.header-info {
  flex: 1;
}

.header-info h2 {
  margin: 0 0 8px 0;
  font-size: 24px;
  color: #303133;
}

.contact-info {
  margin: 0 0 12px 0;
  color: #666;
}

.contact-info span {
  margin-right: 16px;
}

.basic-tags {
  display: flex;
  gap: 8px;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.resume-tabs {
  margin-top: 20px;
}

.resume-section {
  padding: 20px 0;
}

.resume-section h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: #303133;
  border-bottom: 2px solid #409eff;
  padding-bottom: 8px;
}

.experience-item,
.education-item {
  margin-bottom: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.exp-header,
.edu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.exp-header h4,
.edu-header h4 {
  margin: 0;
  font-size: 16px;
  color: #303133;
}

.exp-duration,
.edu-duration {
  color: #666;
  font-size: 14px;
}

.exp-description,
.edu-degree {
  margin: 0;
  color: #666;
  line-height: 1.6;
}

.skills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-tag {
  margin: 0;
}

.self-evaluation {
  line-height: 1.8;
  color: #666;
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
  margin: 0;
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    gap: 16px;
  }

  .header-right {
    align-self: stretch;
    justify-content: space-between;
  }

  .stats-row .el-col {
    margin-bottom: 12px;
  }

  .table-toolbar {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .resume-header {
    flex-direction: column;
    text-align: center;
  }

  .header-actions {
    flex-direction: row;
    justify-content: center;
  }
}
</style>
